package com.lh.java.junit;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class TestSquareRoot {
	private static Calculator calculator = new Calculator();
	private int param;
	private int result;

	@SuppressWarnings("rawtypes")
	@Parameters
	public static Collection date() {
		return Arrays.asList(new Object[][] { 
				{4,2},{ -4,-2},{ 0,0},{null,null},{0,null},{null,0}
		
		});
	}
	
	public TestSquareRoot(int param, int result){
		this.param = param;
		this.result = result;		
	}

	@Before
	public void setUp() throws Exception {
		calculator.clear();
	}

	@Test
	public void testSquareRoot() {
		int a = calculator.squareRoot(param);
		assertEquals(result, a);
	}

}
